products = [["iphone", 6888], ["MacPro", 14800], ["小米6", 2499], ["Coffee", 31], ["Book", 60], ["Nike", 699]]
print("-------------- 商品列表 ------------------")

shop_car = []
shop_cost = []
shop_id = 0
flag = 1
for shop, cost in products:
    shop_id += 1
    print(shop_id, shop, cost, sep='\t')
while flag:
    buy = input("请输入你要购买的商品标号，如果你想退出请输入q:")
    if buy == "q":
        flag = 0
    elif buy in str(list(range(len(products) + 1))):
        shop_cost.append(products[int(buy) - 1][0])
        shop_car.append(products[int(buy) - 1][1])
    else:
        print("输入有误，" + "商品编号应在"+ str(len(products))+"以内")
print("您所选购的商品为{},您需要支付{}元".format(shop_cost, shop_car))
sum=0
for cost in shop_car:
    sum += cost

print("您共需要支付" + str(sum)+"元")

# 再来个购买成功的






